<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教练评价</title>
    <link rel="stylesheet" href="./css/fore/order.css">
    <link rel="stylesheet" href="./css/fore/index.css">
    <link rel="stylesheet" href="css/fore/comment.css">
    <script src="./js/jquery/2.0.0/jquery.min.js"></script>
    <link href="./css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
    <script src="./js/bootstrap/3.3.6/bootstrap.min.js"></script>
    <script src="./js/vue.min.js"></script>
    <script src="./js/fetch.min.js"></script>
    <script src="./js/axios.min.js"></script>

</head>
<body>
<div class="header">
    <div class="top">
        <div class="top-logo fl">
            <a id="logo" href="#" target="_blank">
                <img src="./img/car-logo.png" alt="" class="fl"
                     style="margin-top: 20px;width: 45px"><span class="top-logo-text">教练评价</span></a>
        </div>
    </div>
</div>
<div class="header-nav">
    <ul id="nav-list">
        <li class="nav-list-li"><a href="index.html">回到首页</a></li>
        <li class="nav-list-li"><a href="#">教练评价</a></li>
    </ul>
</div>
<div class="headlineC" id="allContent">
    <div class="headline">
        <div class="icon fl"><img src="./img/headline_icon.png"></div>
        <h2 class="_headline-title" align="center">教练评价</h2>
    </div>


    <div class="panel panel-default" id="t1" v-for="c in cs">
        <div class="panel-heading eachCommentDiv-heading">
            <span class="smallword text-muted">{{c.timeStr}}</span>
            <span role="button" class="glyphicon glyphicon-resize-small pull-right"
                  data-toggle="collapse" href="#collapseOne"
            ></span>
        </div>
        <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
            <div class="panel-body">
                <table width="100%" class="eachCommentTable">
                    <tbody>
                    <tr valign="center">
                        <td width="100px">
                            <span>
                                <img :src="['img/student/' + c.user.pic]" width="30px" height="30px">
                            </span>
                            <span>{{c.student.name}}:</span>
                            <br>
                        </td>
                        <td align="left">
                            {{c.content}}
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="commitComment">
        <div>提交评价</div>
        <br>
        <form method="post" id="addForm" action="addComment" enctype="multipart/form-data">
            <input type="hidden" name="cid" v-model="cid">
            <textarea class="form-control" rows="9" name="content" required></textarea>
            <br>
            <button type="submit" class="btn btn-success">提 交</button>
        </form>
    </div>
</div>


<div class="footer">
    <p>
        Good CarTeacher©2018 | QQ:123456789
        <a href="#">|关于我们</a>
        <a href="login.html">|驾校登录</a>
    </p>
</div>
<script>
    function GetQueryString(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)
            return  unescape(r[2]);
        return null;
    }
    let url = "fore_student_listCommentByCid";
    new Vue({
        el: '#allContent',
        data: {
            cs: [],
            cid: []
        },
        mounted: function () {
            self = this;
            url += ("?cid=" + GetQueryString("cid"));
            console.log(url);
            fetch(url).then(function (response) {
                response.json().then(function (jsonObject) {
                    console.log(jsonObject);
                    self.cs = jsonObject.cs;
                    self.cid = jsonObject.cid;
                    if(GetQueryString("msg") == -1) {
                        alert("只能评价自己的教练哦！！！");
                    }
                }).catch(function (err) {
                    console.log("Fetch错误：" + err);
                })
            })
        },
        methods:{
            forward: function(){
                var d = this.stringToDate();
                d.setDate(d.getDate()-7);
                this.t=d.getTime();
                this.request(d);
            },
        }
    });
</script>
</body>
</html>